const protoRoot = (protobuf.roots['default'] || (protobuf.roots['default'] = new protobuf.Root()))
  .addJSON({
    jd: {
      nested: {
        datasource: {
          nested: {
            quotation: {
              nested: {
                api: {
                  options: {
                    java_package: 'com.jd.datasource.quotation.api',
                    java_outer_classname: 'SubUnsubProto'
                  },
                  nested: {
                    BizResult: {
                      values: {
                        kNoError: 0,
                        kHasNoData: 1,
                        kNotSupported: 2,
                        kErrorRequest: 3,
                        kRepeatedSub: 4,
                        kHasNotSub: 5,
                        kUnknownError: 6
                      }
                    },
                    Result: {
                      fields: {
                        result: {
                          type: 'BizResult',
                          id: 1
                        },
                        resultMessage: {
                          type: 'string',
                          id: 2
                        }
                      }
                    },
                    ContractKey: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        }
                      }
                    },
                    SortType: {
                      values: {
                        asc: 0,
                        desc: 1
                      }
                    },
                    CommodityInfo: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        commodityName: {
                          type: 'string',
                          id: 4
                        },
                        volunit: {
                          type: 'double',
                          id: 5
                        },
                        MPC: {
                          type: 'double',
                          id: 6
                        },
                        mtss: {
                          rule: 'repeated',
                          type: 'string',
                          id: 7
                        },
                        centralizedBiddingSession: {
                          rule: 'repeated',
                          type: 'string',
                          id: 8
                        },
                        tradingContinous: {
                          rule: 'repeated',
                          type: 'string',
                          id: 9
                        },
                        csi: {
                          type: 'string',
                          id: 10
                        },
                        industryName: {
                          type: 'string',
                          id: 11
                        },
                        areaName: {
                          type: 'string',
                          id: 12
                        },
                        contractKey: {
                          type: 'ContractKey',
                          id: 13
                        },
                        indexCnName: {
                          type: 'string',
                          id: 14
                        },
                        stockFlag: {
                          type: 'string',
                          id: 15
                        }
                      }
                    },
                    KLineType: {
                      values: {
                        kMinute: 0,
                        kDay: 1,
                        k5Minute: 2,
                        k15Minute: 3,
                        k30Minute: 4,
                        k1Hour: 5,
                        kWeek: 9,
                        kMonth: 10,
                        kQuarter: 11,
                        kYear: 12
                      }
                    },
                    GetKLineRequest: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        },
                        type: {
                          type: 'KLineType',
                          id: 5
                        },
                        beginTime: {
                          type: 'string',
                          id: 6
                        },
                        endTime: {
                          type: 'string',
                          id: 7
                        },
                        count: {
                          type: 'fixed32',
                          id: 8
                        }
                      }
                    },
                    KLineData: {
                      fields: {
                        openPrice: {
                          type: 'double',
                          id: 1
                        },
                        highPrice: {
                          type: 'double',
                          id: 2
                        },
                        lowPrice: {
                          type: 'double',
                          id: 3
                        },
                        closePrice: {
                          type: 'double',
                          id: 4
                        },
                        volume: {
                          type: 'fixed64',
                          id: 5
                        },
                        timestamp: {
                          type: 'string',
                          id: 7
                        },
                        turnover: {
                          type: 'double',
                          id: 8
                        },
                        preClose: {
                          type: 'double',
                          id: 9
                        },
                        raisePercent: {
                          type: 'double',
                          id: 10
                        },
                        raise: {
                          type: 'double',
                          id: 11
                        },
                        amplitude: {
                          type: 'double',
                          id: 12
                        }
                      }
                    },
                    GetKLineResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        contractNo: {
                          type: 'string',
                          id: 5
                        },
                        type: {
                          type: 'KLineType',
                          id: 6
                        },
                        listKLineData: {
                          rule: 'repeated',
                          type: 'KLineData',
                          id: 7
                        }
                      }
                    },
                    GetLastPriceRequest: {
                      fields: {
                        listContract: {
                          rule: 'repeated',
                          type: 'ContractKey',
                          id: 1
                        }
                      }
                    },
                    LastPrice: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        contractNo: {
                          type: 'string',
                          id: 5
                        },
                        lastPrice: {
                          type: 'double',
                          id: 6
                        },
                        totalVolume: {
                          type: 'fixed64',
                          id: 7
                        },
                        timestamp: {
                          type: 'string',
                          id: 8
                        }
                      }
                    },
                    GetLastPriceResponse: {
                      fields: {
                        listLastPrice: {
                          rule: 'repeated',
                          type: 'LastPrice',
                          id: 1
                        }
                      }
                    },
                    GetSnapshotRequest: {
                      fields: {
                        listContract: {
                          rule: 'repeated',
                          type: 'ContractKey',
                          id: 1
                        }
                      }
                    },
                    Snapshot: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        contractNo: {
                          type: 'string',
                          id: 5
                        },
                        openPrice: {
                          type: 'double',
                          id: 6
                        },
                        lastPrice: {
                          type: 'double',
                          id: 7
                        },
                        highPrice: {
                          type: 'double',
                          id: 8
                        },
                        lowPrice: {
                          type: 'double',
                          id: 9
                        },
                        preClosePrice: {
                          type: 'double',
                          id: 10
                        },
                        limitUpPrice: {
                          type: 'double',
                          id: 11
                        },
                        limitDownPrice: {
                          type: 'double',
                          id: 12
                        },
                        totalVolume: {
                          type: 'fixed64',
                          id: 13
                        },
                        totalTurnover: {
                          type: 'double',
                          id: 14
                        },
                        listBidPrice: {
                          rule: 'repeated',
                          type: 'double',
                          id: 15
                        },
                        listBidVolume: {
                          rule: 'repeated',
                          type: 'fixed64',
                          id: 16
                        },
                        listAskPrice: {
                          rule: 'repeated',
                          type: 'double',
                          id: 17
                        },
                        listAskVolume: {
                          rule: 'repeated',
                          type: 'fixed64',
                          id: 18
                        },
                        timestamp: {
                          type: 'string',
                          id: 19
                        },
                        averagePrice: {
                          type: 'double',
                          id: 20
                        },
                        turnoverRate: {
                          type: 'double',
                          id: 21
                        },
                        peRatio: {
                          type: 'double',
                          id: 22
                        },
                        totalValue: {
                          type: 'double',
                          id: 23
                        },
                        changeSpeed: {
                          type: 'double',
                          id: 24
                        },
                        changeRate: {
                          type: 'double',
                          id: 25
                        },
                        changeValue: {
                          type: 'double',
                          id: 26
                        },
                        swing: {
                          type: 'double',
                          id: 27
                        },
                        currencyShare: {
                          type: 'double',
                          id: 28
                        },
                        totalShare: {
                          type: 'double',
                          id: 29
                        },
                        earningsPerShare: {
                          type: 'double',
                          id: 30
                        },
                        realPeRatio: {
                          type: 'double',
                          id: 31
                        },
                        lastVolume: {
                          type: 'double',
                          id: 32
                        },
                        peTtmEd: {
                          type: 'double',
                          id: 33
                        },
                        pbLastestEd: {
                          type: 'double',
                          id: 34
                        },
                        pcfTtmEd: {
                          type: 'double',
                          id: 35
                        },
                        psTtmEd: {
                          type: 'double',
                          id: 36
                        },
                        npPerShare: {
                          type: 'double',
                          id: 37
                        },
                        earningsPerShareTTM: {
                          type: 'double',
                          id: 38
                        },
                        incomePerShare: {
                          type: 'double',
                          id: 39
                        },
                        netCfPs: {
                          type: 'double',
                          id: 40
                        },
                        day3ChangeRate: {
                          type: 'double',
                          id: 41
                        },
                        day20ChangeRate: {
                          type: 'double',
                          id: 42
                        },
                        day60ChangeRate: {
                          type: 'double',
                          id: 43
                        },
                        dayTodayYearChangeRate: {
                          type: 'double',
                          id: 44
                        },
                        volumeRate: {
                          type: 'double',
                          id: 45
                        },
                        inVolume: {
                          type: 'fixed64',
                          id: 46
                        },
                        outVolume: {
                          type: 'fixed64',
                          id: 47
                        },
                        upCount: {
                          type: 'int32',
                          id: 49
                        },
                        flatCount: {
                          type: 'int32',
                          id: 50
                        },
                        downCount: {
                          type: 'int32',
                          id: 51
                        },
                        floatMarketValue: {
                          type: 'double',
                          id: 52
                        },
                        totalMarketValue: {
                          type: 'double',
                          id: 53
                        }
                      }
                    },
                    GetSnapshotResponse: {
                      fields: {
                        listSnapshot: {
                          rule: 'repeated',
                          type: 'Snapshot',
                          id: 1
                        }
                      }
                    },
                    CommodityKey: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        }
                      }
                    },
                    GetContractStatusRequest: {
                      fields: {
                        listCommodity: {
                          rule: 'repeated',
                          type: 'CommodityKey',
                          id: 1
                        }
                      }
                    },
                    Status: {
                      values: {
                        kInitialize: 0,
                        kCallAction: 1,
                        kPreTransaction: 2,
                        kContinous: 3,
                        kContinousRest: 4,
                        kPostTransaction: 5,
                        kClosed: 6
                      }
                    },
                    ContractStatus: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        status: {
                          type: 'Status',
                          id: 5
                        }
                      }
                    },
                    GetContractStatusResponse: {
                      fields: {
                        listStatus: {
                          rule: 'repeated',
                          type: 'ContractStatus',
                          id: 1
                        }
                      }
                    },
                    GetTransactionRequest: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        },
                        count: {
                          type: 'int32',
                          id: 5
                        },
                        timestamp: {
                          type: 'string',
                          id: 6
                        }
                      }
                    },
                    Direction: {
                      values: {
                        kFlat: 0,
                        kShort: 1,
                        kLong: 2
                      }
                    },
                    TransactionDetail: {
                      fields: {
                        price: {
                          type: 'double',
                          id: 1
                        },
                        volume: {
                          type: 'fixed64',
                          id: 2
                        },
                        timestamp: {
                          type: 'string',
                          id: 3
                        },
                        direction: {
                          type: 'Direction',
                          id: 4
                        }
                      }
                    },
                    GetTransactionResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        contractNo: {
                          type: 'string',
                          id: 5
                        },
                        listTransaction: {
                          rule: 'repeated',
                          type: 'TransactionDetail',
                          id: 6
                        }
                      }
                    },
                    GetTrendRequest: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        }
                      }
                    },
                    Trend: {
                      fields: {
                        price: {
                          type: 'double',
                          id: 1
                        },
                        turnover: {
                          type: 'double',
                          id: 2
                        },
                        volume: {
                          type: 'fixed64',
                          id: 3
                        },
                        totalTurnover: {
                          type: 'double',
                          id: 4
                        },
                        totalVolume: {
                          type: 'fixed64',
                          id: 5
                        },
                        timestamp: {
                          type: 'string',
                          id: 6
                        },
                        avg: {
                          type: 'double',
                          id: 7
                        },
                        preClose: {
                          type: 'double',
                          id: 8
                        }
                      }
                    },
                    GetTrendResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        contractNo: {
                          type: 'string',
                          id: 5
                        },
                        timepoint: {
                          rule: 'repeated',
                          type: 'string',
                          id: 6
                        },
                        trend: {
                          rule: 'repeated',
                          type: 'Trend',
                          id: 7
                        }
                      }
                    },
                    ListCommodityRequest: {
                      fields: {
                        contractKeys: {
                          rule: 'repeated',
                          type: 'ContractKey',
                          id: 1
                        }
                      }
                    },
                    ListCommodityResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        listCommodity: {
                          rule: 'repeated',
                          type: 'CommodityInfo',
                          id: 2
                        }
                      }
                    },
                    CStockRequest: {
                      fields: {
                        contractKey: {
                          type: 'ContractKey',
                          id: 1
                        },
                        sortType: {
                          type: 'SortType',
                          id: 2
                        },
                        startSeq: {
                          type: 'int32',
                          id: 3
                        },
                        endSeq: {
                          type: 'int32',
                          id: 4
                        }
                      }
                    },
                    CStockResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        listCommodity: {
                          rule: 'repeated',
                          type: 'CommodityInfo',
                          id: 2
                        }
                      }
                    },
                    Commodity: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        }
                      }
                    },
                    ListContractRequest: {
                      fields: {
                        listCommodity: {
                          rule: 'repeated',
                          type: 'Commodity',
                          id: 1
                        }
                      }
                    },
                    ListContract: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        listContract: {
                          rule: 'repeated',
                          type: 'string',
                          id: 5
                        }
                      }
                    },
                    ListContractResponse: {
                      fields: {
                        listContract: {
                          rule: 'repeated',
                          type: 'ListContract',
                          id: 1
                        }
                      }
                    },
                    ListExchangeRequest: {
                      fields: {}
                    },
                    ExchangeInfo: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        tradingTime: {
                          rule: 'repeated',
                          type: 'string',
                          id: 2
                        }
                      }
                    },
                    ListExchangeResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        listExchangeInfo: {
                          rule: 'repeated',
                          type: 'ExchangeInfo',
                          id: 3
                        }
                      }
                    },
                    ListMultiSharesRequest: {
                      fields: {
                        contractKey: {
                          type: 'ContractKey',
                          id: 1
                        },
                        multiSharesNum: {
                          type: 'int32',
                          id: 2
                        }
                      }
                    },
                    ListMultiSharesResponse: {
                      fields: {
                        listCommodity: {
                          rule: 'repeated',
                          type: 'CommodityInfo',
                          id: 2
                        }
                      }
                    },
                    PageFlag: {
                      values: {
                        stockHomePage: 0,
                        indexHomePage: 1
                      }
                    },
                    ListSearchRequest: {
                      fields: {
                        content: {
                          type: 'string',
                          id: 1
                        },
                        pageFlag: {
                          type: 'PageFlag',
                          id: 2
                        }
                      }
                    },
                    ListSearchResponse: {
                      fields: {
                        listContract: {
                          rule: 'repeated',
                          type: 'CommodityInfo',
                          id: 1
                        }
                      }
                    },
                    SortKey: {
                      values: {
                        sortByA: 0,
                        sortBySem: 1,
                        sortByGem: 2,
                        sortByStart: 3,
                        sortByB: 4,
                        sortByI: 5
                      }
                    },
                    ListSortRequest: {
                      fields: {
                        sortKey: {
                          type: 'SortKey',
                          id: 1
                        },
                        startSeq: {
                          type: 'int32',
                          id: 2
                        },
                        endSeq: {
                          type: 'int32',
                          id: 3
                        },
                        sortType: {
                          type: 'SortType',
                          id: 4
                        }
                      }
                    },
                    ListSortResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        listCommodity: {
                          rule: 'repeated',
                          type: 'CommodityInfo',
                          id: 2
                        }
                      }
                    },
                    UpDownRankKey: {
                      values: {
                        upRank: 0,
                        downRank: 1
                      }
                    },
                    ListUpDownRankRequest: {
                      fields: {
                        contractKey: {
                          type: 'ContractKey',
                          id: 1
                        },
                        upDownRank: {
                          type: 'UpDownRankKey',
                          id: 2
                        },
                        startSeq: {
                          type: 'int32',
                          id: 3
                        },
                        endSeq: {
                          type: 'int32',
                          id: 4
                        }
                      }
                    },
                    RankResponse: {
                      fields: {
                        contractKey: {
                          type: 'ContractKey',
                          id: 1
                        },
                        name: {
                          type: 'string',
                          id: 2
                        },
                        lastPrice: {
                          type: 'double',
                          id: 3
                        },
                        changeRate: {
                          type: 'double',
                          id: 4
                        },
                        changeValue: {
                          type: 'double',
                          id: 5
                        }
                      }
                    },
                    ListUpDownRankResponse: {
                      fields: {
                        listRankResponse: {
                          rule: 'repeated',
                          type: 'RankResponse',
                          id: 1
                        }
                      }
                    },
                    UnsubResult: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        exchangeNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityNo: {
                          type: 'string',
                          id: 3
                        },
                        commodityType: {
                          type: 'string',
                          id: 4
                        },
                        contractNo: {
                          type: 'string',
                          id: 5
                        }
                      }
                    },
                    QuoteBasic: {
                      fields: {
                        lastPrice: {
                          type: 'double',
                          id: 1
                        },
                        highPrice: {
                          type: 'double',
                          id: 2
                        },
                        lowPrice: {
                          type: 'double',
                          id: 3
                        },
                        totalVolume: {
                          type: 'fixed64',
                          id: 4
                        },
                        totalTurnover: {
                          type: 'double',
                          id: 5
                        },
                        averagePrice: {
                          type: 'double',
                          id: 6
                        }
                      }
                    },
                    BidAskQueue: {
                      fields: {
                        totalBidVolume: {
                          type: 'fixed64',
                          id: 1
                        },
                        totalAskVolume: {
                          type: 'fixed64',
                          id: 2
                        },
                        listBidPrice: {
                          rule: 'repeated',
                          type: 'double',
                          id: 3
                        },
                        listBidVolume: {
                          rule: 'repeated',
                          type: 'fixed64',
                          id: 4
                        },
                        listAskPrice: {
                          rule: 'repeated',
                          type: 'double',
                          id: 5
                        },
                        listAskVolume: {
                          rule: 'repeated',
                          type: 'fixed64',
                          id: 6
                        }
                      }
                    },
                    QuoteAdditional: {
                      fields: {
                        tradingState: {
                          type: 'string',
                          id: 1
                        },
                        timestamp: {
                          type: 'string',
                          id: 2
                        },
                        preClosePrice: {
                          type: 'double',
                          id: 3
                        },
                        openPrice: {
                          type: 'double',
                          id: 4
                        },
                        limitUpPrice: {
                          type: 'double',
                          id: 5
                        },
                        limitDownPrice: {
                          type: 'double',
                          id: 6
                        },
                        closePrice: {
                          type: 'double',
                          id: 7
                        },
                        turnoverRate: {
                          type: 'double',
                          id: 8
                        },
                        peRatio: {
                          type: 'double',
                          id: 9
                        },
                        totalValue: {
                          type: 'double',
                          id: 10
                        },
                        changeSpeed: {
                          type: 'double',
                          id: 11
                        },
                        changeRate: {
                          type: 'double',
                          id: 12
                        },
                        changeValue: {
                          type: 'double',
                          id: 13
                        },
                        swing: {
                          type: 'double',
                          id: 14
                        },
                        currencyShare: {
                          type: 'double',
                          id: 15
                        },
                        totalShare: {
                          type: 'double',
                          id: 16
                        },
                        earningsPerShare: {
                          type: 'double',
                          id: 17
                        },
                        realPeRatio: {
                          type: 'double',
                          id: 18
                        },
                        lastVolume: {
                          type: 'double',
                          id: 19
                        },
                        peTtmEd: {
                          type: 'double',
                          id: 20
                        },
                        pbLastestEd: {
                          type: 'double',
                          id: 21
                        },
                        pcfTtmEd: {
                          type: 'double',
                          id: 22
                        },
                        psTtmEd: {
                          type: 'double',
                          id: 23
                        },
                        npPerShare: {
                          type: 'double',
                          id: 24
                        },
                        earningsPerShareTTM: {
                          type: 'double',
                          id: 25
                        },
                        incomePerShare: {
                          type: 'double',
                          id: 26
                        },
                        netCfPs: {
                          type: 'double',
                          id: 27
                        },
                        day3ChangeRate: {
                          type: 'double',
                          id: 28
                        },
                        day20ChangeRate: {
                          type: 'double',
                          id: 29
                        },
                        day60ChangeRate: {
                          type: 'double',
                          id: 30
                        },
                        dayTodayYearChangeRate: {
                          type: 'double',
                          id: 31
                        },
                        volumeRate: {
                          type: 'double',
                          id: 32
                        },
                        inVolume: {
                          type: 'fixed64',
                          id: 33
                        },
                        outVolume: {
                          type: 'fixed64',
                          id: 34
                        },
                        upCount: {
                          type: 'int32',
                          id: 49
                        },
                        flatCount: {
                          type: 'int32',
                          id: 50
                        },
                        downCount: {
                          type: 'int32',
                          id: 51
                        },
                        floatMarketValue: {
                          type: 'double',
                          id: 52
                        },
                        totalMarketValue: {
                          type: 'double',
                          id: 53
                        }
                      }
                    },
                    QuoteContent: {
                      fields: {
                        timestamp: {
                          type: 'string',
                          id: 1
                        },
                        basic: {
                          type: 'QuoteBasic',
                          id: 2
                        },
                        bidAskQueue: {
                          type: 'BidAskQueue',
                          id: 3
                        },
                        additional: {
                          type: 'QuoteAdditional',
                          id: 4
                        }
                      }
                    },
                    ListQuoteContent: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        },
                        listContent: {
                          rule: 'repeated',
                          type: 'QuoteContent',
                          id: 5
                        }
                      }
                    },
                    SubQuoteDetailRequest: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        }
                      }
                    },
                    SubQuoteDetailResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        quotation: {
                          type: 'ListQuoteContent',
                          id: 2
                        }
                      }
                    },
                    UnsubQuoteDetailRequest: {
                      fields: {
                        exchangeNo: {
                          type: 'string',
                          id: 1
                        },
                        commodityNo: {
                          type: 'string',
                          id: 2
                        },
                        commodityType: {
                          type: 'string',
                          id: 3
                        },
                        contractNo: {
                          type: 'string',
                          id: 4
                        }
                      }
                    },
                    UnsubQuoteDetailResponse: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        }
                      }
                    },
                    QuoteTip: {
                      fields: {
                        result: {
                          type: 'Result',
                          id: 1
                        },
                        listQuoteContent: {
                          type: 'ListQuoteContent',
                          id: 2
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  })

const arrayBuffer = {
  fromBase64(str) {
    const rawData = atob(str)
    const arr = new Uint8Array(rawData.length)

    for (let i = 0; i < rawData.length; ++i) {
      arr[i] = rawData.charCodeAt(i)
    }
    return arr
  },
  toBase64(buf) {
    let str = ''
    const bytes = new Uint8Array(buf)
    const len = bytes.byteLength
    for (let i = 0; i < len; i++) {
      str += String.fromCharCode(bytes[i])
    }
    return btoa(str)
  }
}

const protoBuf = {
  encodeToBase64(protoName, obj) {
    const proto = protoRoot.lookupType(protoName)
    const buf = proto.encode(proto.create(obj)).finish()
    return arrayBuffer.toBase64(buf)
  },
  decodeFromBase64(protoName, base64) {
    const proto = protoRoot.lookupType(protoName)
    const buf = arrayBuffer.fromBase64(base64)
    return proto.decode(buf)
  }
}